home *** CD-ROM | disk | FTP | other *** search
/ SGI Freeware 1999 August / SGI Freeware 1999 August.iso / dist / fw_plotutils.idb / usr / freeware / share / ode / orbit.ode.z / orbit.ode
Encoding:
Text File  |  1998-10-28  |  1.0 KB  |  42 lines

  1. # This example does a planetary orbit simulation, with two suns situated at
  2. # (0,0) and (-5,0) and one planet starting out at (1,0).  You may run it by
  3. # typing
  4.  
  5. #    ode -f orbit.ode | graph -T X -C -y -1 3 -x -6 2
  6. #    step 0,10
  7. #    step 10,20
  8. #    step 20,30
  9. #    step 30,40
  10. #    step 40,50
  11. #    step 50,60
  12. #    .
  13.  
  14. # The planet's orbit will be traced out incrementally.  If you are using a
  15. # color X Window System display, each segment of the orbit will be a
  16. # different color.  This is a feature provided by `graph', which normally
  17. # changes the linemode after each dataset it reads. If you do not like this
  18. # feature, you may turn it off by using `graph -B' instead of `graph'.
  19.  
  20. # x and y are positions
  21. # vx and vy are velocities
  22.  
  23. vx' = -x/((x^2+y^2)^(3/2)) -(x+5)/(((x+5)^2+y^2)^(3/2))
  24. vy' = -y/((x^2+y^2)^(3/2)) -y/(((x+5)^2+y^2)^(3/2))
  25. y' = vy
  26. x' = vx
  27.  
  28. x = 1
  29. y = 0
  30.  
  31. print x,y every 5
  32.  
  33. # these values seem to give a nice orbit:
  34. # vx = 0
  35. # vy = 1.142
  36.  
  37. # a more exciting result can be obtained from:
  38. vx = 0
  39. vy = 1.165
  40.  
  41. #step 0,20
  42.